﻿using Desktop.Controls;
using System;
using System.Collections.Generic;

namespace Desktop.Library
{
    public struct WorkspaceDescriptor
    {
        #region Constructors

        public WorkspaceDescriptor(string name, bool isCloseable, params Type[] activities)
            : this()
        {
            Name = name;
            IsCloseable = isCloseable;
            Activities = new List<Type>(activities);
        }

        #endregion

        #region Properties

        public string Name { get; private set; }
        public bool IsCloseable { get; private set; }
        public List<Type> Activities { get; private set; }

        #endregion

        #region Methods

        public Workspace Open(Application app)
        {
            Workspace ws = new Workspace(app);
            ws.WorkspaceName = Name;
            ws.IsCloseable = IsCloseable;
            foreach (Type t in Activities)
            {
                ws.OpenActivity(Activator.CreateInstance(t, new object[] { ws }) as ActivityBase);
            }
            app.OpenWorkspace(ws);
            return ws;
        }

        #endregion
    }
}
